import 'package:flutter/material.dart';

class AnimationIconScreen extends StatefulWidget {

  @override
  _AnimationIconScreenState createState() => _AnimationIconScreenState();
}

class _AnimationIconScreenState extends State<AnimationIconScreen> with SingleTickerProviderStateMixin {

  AnimationController _animationController;
  Animation<double> _animation;

  @override
  void initState() {
    super.initState();
    _animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 200));
    CurvedAnimation _cure = CurvedAnimation(curve: Curves.bounceInOut, parent: _animationController);
    _animation = Tween<double>(begin: 0, end: 1).animate(_cure)
      ..addListener((){
        setState(() {
          
        });
      })..addStatusListener((status){
      });
  }

  @override
  void dispose() {
    _animationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("AnimationIcon"),
        leading: IconButton(
          icon: Icon(Icons.arrow_back),
          onPressed: (){
            Navigator.of(context).pop();
          },
        ),
      ),
      body: Container(
        child: AnimatedIcon(
          icon: AnimatedIcons.close_menu,
          progress: _animation,
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: (){
          if(_animationController.isCompleted){
            _animationController.reverse();
          } else {
            _animationController.forward();
          }
        },
      ),
    );
  }
}